package com.csmz.enterprise.service.impl;

import com.csmz.common.utils.DateUtils;
import com.csmz.common.utils.SecurityUtils;
import com.csmz.enterprise.domain.CsmzParttimePosition;
import com.csmz.enterprise.mapper.CsmzParttimePositionMapper;
import com.csmz.enterprise.service.ICsmzParttimePositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 兼职岗位Service业务层处理
 * 
 * @author TT
 * @date 2025-09-17
 */
@Service
public class CsmzParttimePositionServiceImpl implements ICsmzParttimePositionService 
{
    @Autowired
    private CsmzParttimePositionMapper csmzParttimePositionMapper;

    /**
     * 查询兼职岗位
     * 
     * @param id 兼职岗位主键
     * @return 兼职岗位
     */
    @Override
    public CsmzParttimePosition selectCsmzParttimePositionById(Long id)
    {
        return csmzParttimePositionMapper.selectCsmzParttimePositionById(id);
    }

    /**
     * 查询兼职岗位列表
     * 
     * @param csmzParttimePosition 兼职岗位
     * @return 兼职岗位
     */
    @Override
    public List<CsmzParttimePosition> selectCsmzParttimePositionList(CsmzParttimePosition csmzParttimePosition)
    {
        return csmzParttimePositionMapper.selectCsmzParttimePositionList(csmzParttimePosition);
    }

    /**
     * 新增兼职岗位
     * 
     * @param csmzParttimePosition 兼职岗位
     * @return 结果
     */
    @Override
    public int insertCsmzParttimePosition(CsmzParttimePosition csmzParttimePosition)
    {
        csmzParttimePosition.setCreateTime(DateUtils.getNowDate());
        return csmzParttimePositionMapper.insertCsmzParttimePosition(csmzParttimePosition);
    }

    /**
     * 修改兼职岗位
     * 
     * @param csmzParttimePosition 兼职岗位
     * @return 结果
     */
    @Override
    public int updateCsmzParttimePosition(CsmzParttimePosition csmzParttimePosition)
    {
        csmzParttimePosition.setUpdateTime(DateUtils.getNowDate());
        return csmzParttimePositionMapper.updateCsmzParttimePosition(csmzParttimePosition);
    }

    /**
     * 批量删除兼职岗位
     * 
     * @param ids 需要删除的兼职岗位主键
     * @return 结果
     */
    @Override
    public int deleteCsmzParttimePositionByIds(Long[] ids)
    {
        return csmzParttimePositionMapper.deleteCsmzParttimePositionByIds(ids);
    }

    /**
     * 删除兼职岗位信息
     * 
     * @param id 兼职岗位主键
     * @return 结果
     */
    @Override
    public int deleteCsmzParttimePositionById(Long id)
    {
        return csmzParttimePositionMapper.deleteCsmzParttimePositionById(id);
    }

    /**
     *  查询我公司发布的兼职岗位列表
     * @param csmzParttimePosition 兼职岗位
     * @return 兼职岗位集合
     */
    @Override
    public List<CsmzParttimePosition> selectMyCsmzParttimePositionList(CsmzParttimePosition csmzParttimePosition) {
        // 获取当前用户ID
        Long userId = SecurityUtils.getUserId();
        // 设置查询条件
        csmzParttimePosition.setUserId(userId);
        // 根据条件查询我公司发布的兼职岗位列表
       return csmzParttimePositionMapper.selectCsmzParttimePositionList(csmzParttimePosition);
    }

    /**
     *  新增我公司发布兼职岗位
     * @param csmzParttimePosition 兼职岗位
     * @return  结果
     */
    @Override
    public int insertMyCsmzParttimePosition(CsmzParttimePosition csmzParttimePosition) {
        // 获取当前用户ID
        Long userId = SecurityUtils.getUserId();
        csmzParttimePosition.setUserId(userId);
        return csmzParttimePositionMapper.insertCsmzParttimePosition(csmzParttimePosition);
    }
}
